﻿package view.mainUI
{
    import com.core.*;
    import com.greensock.*;
    import com.greensock.easing.*;
    import com.sh.game.util.*;
    import flash.display.*;
    import flash.utils.*;
    import uiresource.*;

    public class MoBaiExp extends MoBaiExpUI
    {
        private var cdMask:Sprite;
        private var tweenLite:TweenLite;
        private var _intvalid:uint = 0;
        private var _time:int;
        private var _exp:int;

        public function MoBaiExp()
        {
            this.cdMask = new Sprite();
            this.cdMask.graphics.beginFill(16777215, 1);
            this.cdMask.graphics.drawRect(cd.x, cd.y, cd.width, cd.height);
            this.cdMask.graphics.endFill();
            this.cdMask.visible = false;
            this.addChild(this.cdMask);
            cd.mask = this.cdMask;
            return;
        }// end function

        public function show(param1:int) : void
        {
            if (this.visible)
            {
                return;
            }
            var _loc_2:* = UserData.getUserData("level");
            if (_loc_2 < 70)
            {
                return;
            }
            this.visible = true;
            var _loc_3:int = 1;
            while (_loc_3 <= 6)
            {
                
                if (_loc_3 == 1)
                {
                    this["img" + _loc_3].url = "cs2_mobai/0.png";
                    this["img" + _loc_3].visible = true;
                }
                else
                {
                    this["img" + _loc_3].visible = false;
                }
                _loc_3++;
            }
            wan.x = img1.x + 18;
            this.cdMask.width = 0;
            if (this.tweenLite)
            {
                this.tweenLite.kill();
            }
            this.tweenLite = TweenLite.to(this.cdMask, 10, {width:cd.width, ease:Linear.easeNone});
            cdLabel.text = "剩余时间：" + TimeDataFormatUtil.getLeftTimeStr3(param1);
            if (this._intvalid > 0)
            {
                clearInterval(this._intvalid);
            }
            this._time = param1;
            this._intvalid = 0;
            this._intvalid = setInterval(this.autoCounter, 1000);
            ModelProxy.change("data", "mbstart", true);
            return;
        }// end function

        private function autoCounter() : void
        {
            var _loc_1:String = this;
            var _loc_2:* = this._time - 1;
            _loc_1._time = _loc_2;
            cdLabel.text = "剩余时间：" + TimeDataFormatUtil.getLeftTimeStr3(this._time);
            if (this._time == 0)
            {
                this.dipose();
            }
            return;
        }// end function

        private function doCom() : void
        {
            this.cdMask.width = 0;
            this.tweenLite = TweenLite.to(this.cdMask, 10, {width:cd.width, ease:Linear.easeNone});
            return;
        }// end function

        public function upDateExp(param1:int) : void
        {
            var _loc_5:String = null;
            var _loc_2:* = param1 / 10000;
            var _loc_3:* = _loc_2.toString();
            var _loc_4:int = 1;
            while (_loc_4 <= 6)
            {
                
                if (_loc_3.length >= _loc_4)
                {
                    _loc_5 = _loc_3.substr((_loc_4 - 1), 1);
                    if (_loc_5 == ".")
                    {
                        this["img" + _loc_4].url = "cs2_mobai/zero.png";
                    }
                    else
                    {
                        this["img" + _loc_4].url = "cs2_mobai/" + _loc_5 + ".png";
                    }
                    this["img" + _loc_4].visible = true;
                }
                else
                {
                    this["img" + _loc_4].visible = false;
                }
                _loc_4++;
            }
            wan.x = img1.x + 18 * _loc_3.length;
            if (param1 - this._exp < 200000)
            {
                this.doCom();
            }
            this._exp = param1;
            return;
        }// end function

        public function dipose() : void
        {
            if (this._intvalid > 0)
            {
                clearInterval(this._intvalid);
            }
            this._time = 0;
            this._intvalid = 0;
            if (this.tweenLite)
            {
                this.tweenLite.kill();
            }
            this.visible = false;
            ModelProxy.change("data", "mbstart", false);
            return;
        }// end function

    }
}
